package com.hemaapp.yjnh.bean;

import com.android.uu.utils.uuUtils;
import com.google.gson.Gson;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.jar.Attributes;

import xtom.frame.XtomObject;
import xtom.frame.exception.DataParseException;

/**
 * 类描述：帖子详情
 * 创建人：GuiyouZhang
 * 创建时间：2016/8/12 11:37
 * 修改备注：
 */
public class BlogDetail extends XtomObject implements Serializable {

    private String qq;
    private String nickname;
    private String avatar;
    private String address;
    private String mobile;
    private String farmer_starscore;
    private String farmer_replycount;
    private String id;
    private String client_id;
    private String keyid;
    private String type;
    private String name;
    private String parent_typename;
    private String typename;
    private String brand;
    private String product;
    private String material;
    private String sn;
    private String weight;
    private String unit;
    private String ALevel;
    private String organicflag;
    private String islamflag;
    private String days;
    private String leftcount;
    private String topkeytype;
    private String saleflag;
    private String removeflag;
    private String returnflag;
    private String topflag;
    private String cheapflag;
    private String price;
    private String oldprice;
    private String score;
    private String score_percent;
    private String expressfee;
    private String modid;
    private String district_name;
    private String replycount;
    private String goodcount;
    private String sellcount;
    private String collectcount;
    private String starscore;
    private String starcount;
    private String imgurl;
    private String imgurlbig;
    private String picurl;
    private String picurlbig;
    private String imgcount;
    private String img2count;
    private String content;
    private String buycontent;
    private String orderby;
    private String regdate;
    private String one_spec;
    private String two_spec;
    private String spec;
    private String enddate;
    private String volume;
    private String collectflag;
    private String goodflag;
    private List<AttributeItems> attributeItems = new ArrayList<>();
    private List<ImgItemsBean> imgItems = new ArrayList<>();
    private List<ImgItemsBean> img2Items = new ArrayList<>();

    public BlogDetail(JSONObject jsonObject) throws DataParseException {
        if (jsonObject != null) {
            try {
                qq = get(jsonObject, "qq");
                nickname = get(jsonObject, "nickname");
                avatar = get(jsonObject, "avatar");
                address = get(jsonObject, "address");
                mobile = get(jsonObject, "mobile");
                farmer_starscore = get(jsonObject, "farmer_starscore");
                farmer_replycount = get(jsonObject, "farmer_replycount");
                id = get(jsonObject, "id");
                client_id = get(jsonObject, "client_id");
                keyid = get(jsonObject, "keyid");
                type = get(jsonObject, "type");
                name = get(jsonObject, "name");
                parent_typename = get(jsonObject, "parent_typename");
                typename = get(jsonObject, "typename");
                brand = get(jsonObject, "brand");
                product = get(jsonObject, "product");
                material = get(jsonObject, "material");
                sn = get(jsonObject, "sn");
                weight = get(jsonObject, "weight");
                unit = get(jsonObject, "unit");
                ALevel = get(jsonObject, "ALevel");
                organicflag = get(jsonObject, "organicflag");
                islamflag = get(jsonObject, "islamflag");
                days = get(jsonObject, "days");
                leftcount = get(jsonObject, "leftcount");
                topkeytype = get(jsonObject, "topkeytype");
                saleflag = get(jsonObject, "saleflag");
                removeflag = get(jsonObject, "removeflag");
                returnflag = get(jsonObject, "returnflag");
                topflag = get(jsonObject, "topflag");
                cheapflag = get(jsonObject, "cheapflag");;
                price = uuUtils.formatAfterDot2(get(jsonObject, "price"));
                oldprice = uuUtils.formatAfterDot2(get(jsonObject, "oldprice"));
                score = uuUtils.formatAfterDot2(get(jsonObject, "score"));
                score_percent = get(jsonObject, "score_percent");
                expressfee = uuUtils.formatAfterDot2(get(jsonObject, "expressfee"));
                modid = get(jsonObject, "modid");
                district_name = get(jsonObject, "district_name");
                replycount = get(jsonObject, "replycount");
                goodcount = get(jsonObject, "goodcount");
                sellcount = get(jsonObject, "sellcount");
                collectcount = get(jsonObject, "collectcount");
                starscore = get(jsonObject, "starscore");
                starcount = get(jsonObject, "starcount");
                imgurlbig = get(jsonObject, "imgurlbig");
                imgurl = get(jsonObject, "imgurl");
                picurl = get(jsonObject, "picurl");
                picurlbig = get(jsonObject, "picurlbig");
                imgcount = get(jsonObject, "imgcount");
                img2count = get(jsonObject, "img2count");
                content = get(jsonObject, "content");
                buycontent = get(jsonObject, "buycontent");
                orderby = get(jsonObject, "orderby");
                regdate = get(jsonObject, "regdate");
                one_spec = get(jsonObject, "one_spec");
                two_spec = get(jsonObject, "two_spec");
                spec = get(jsonObject, "spec");
                enddate = get(jsonObject, "enddate");
                volume = get(jsonObject, "volume");
                collectflag = get(jsonObject, "collectflag");
                goodflag = get(jsonObject, "goodflag");

                String attri = get(jsonObject, "attributeItems");
                String images1 = get(jsonObject, "imgItems");//轮播图
                String images2 = get(jsonObject, "img2Items");//详情图片

                if (!isNull(attri)) {
                    JSONArray jsons = new JSONArray(attri);
                    for (int i = 0; i < jsons.length(); i++) {
                        JSONObject child = jsons.getJSONObject(i);
                        attributeItems.add(new Gson().fromJson(child.toString(), AttributeItems.class));
                    }
                }

                if (!isNull(images1)) {
                    JSONArray jsons = new JSONArray(images1);
                    for (int i = 0; i < jsons.length(); i++) {
                        JSONObject child = jsons.getJSONObject(i);
                        imgItems.add(new Gson().fromJson(child.toString(), ImgItemsBean.class));
                    }
                }

                if (!isNull(images2)) {
                    JSONArray jsons = new JSONArray(images2);
                    for (int i = 0; i < jsons.length(); i++) {
                        JSONObject child = jsons.getJSONObject(i);
                        img2Items.add(new Gson().fromJson(child.toString(), ImgItemsBean.class));
                    }
                }

                log_i(toString());
            } catch (JSONException e) {
                throw new DataParseException(e);
            }
        }
    }

    public String getQq() {
        return qq;
    }

    public void setQq(String qq) {
        this.qq = qq;
    }

    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public String getFarmer_starscore() {
        return farmer_starscore;
    }

    public void setFarmer_starscore(String farmer_starscore) {
        this.farmer_starscore = farmer_starscore;
    }

    public String getFarmer_replycount() {
        return farmer_replycount;
    }

    public void setFarmer_replycount(String farmer_replycount) {
        this.farmer_replycount = farmer_replycount;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getClient_id() {
        return client_id;
    }

    public void setClient_id(String client_id) {
        this.client_id = client_id;
    }

    public String getKeyid() {
        return keyid;
    }

    public void setKeyid(String keyid) {
        this.keyid = keyid;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getParent_typename() {
        return parent_typename;
    }

    public void setParent_typename(String parent_typename) {
        this.parent_typename = parent_typename;
    }

    public String getTypename() {
        return typename;
    }

    public void setTypename(String typename) {
        this.typename = typename;
    }

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public String getProduct() {
        return product;
    }

    public void setProduct(String product) {
        this.product = product;
    }

    public String getMaterial() {
        return material;
    }

    public void setMaterial(String material) {
        this.material = material;
    }

    public String getSn() {
        return sn;
    }

    public void setSn(String sn) {
        this.sn = sn;
    }

    public String getWeight() {
        return weight;
    }

    public void setWeight(String weight) {
        this.weight = weight;
    }

    public String getUnit() {
        return unit;
    }

    public void setUnit(String unit) {
        this.unit = unit;
    }

    public String getALevel() {
        return ALevel;
    }

    public void setALevel(String ALevel) {
        this.ALevel = ALevel;
    }

    public String getOrganicflag() {
        return organicflag;
    }

    public void setOrganicflag(String organicflag) {
        this.organicflag = organicflag;
    }

    public String getIslamflag() {
        return islamflag;
    }

    public void setIslamflag(String islamflag) {
        this.islamflag = islamflag;
    }

    public String getDays() {
        return days;
    }

    public void setDays(String days) {
        this.days = days;
    }

    public String getLeftcount() {
        return leftcount;
    }

    public void setLeftcount(String leftcount) {
        this.leftcount = leftcount;
    }

    public String getTopkeytype() {
        return topkeytype;
    }

    public void setTopkeytype(String topkeytype) {
        this.topkeytype = topkeytype;
    }

    public String getSaleflag() {
        return saleflag;
    }

    public void setSaleflag(String saleflag) {
        this.saleflag = saleflag;
    }

    public String getRemoveflag() {
        return removeflag;
    }

    public void setRemoveflag(String removeflag) {
        this.removeflag = removeflag;
    }

    public String getReturnflag() {
        return returnflag;
    }

    public void setReturnflag(String returnflag) {
        this.returnflag = returnflag;
    }

    public String getTopflag() {
        return topflag;
    }

    public void setTopflag(String topflag) {
        this.topflag = topflag;
    }

    public String getCheapflag() {
        return cheapflag;
    }

    public void setCheapflag(String cheapflag) {
        this.cheapflag = cheapflag;
    }

    public String getPrice() {
        return price;
    }

    public void setPrice(String price) {
        this.price = price;
    }

    public String getOldprice() {
        return oldprice;
    }

    public void setOldprice(String oldprice) {
        this.oldprice = oldprice;
    }

    public String getScore() {
        return score;
    }

    public void setScore(String score) {
        this.score = uuUtils.formatAfterDot2(score);
    }

    public String getScore_percent() {
        return score_percent;
    }

    public void setScore_percent(String score_percent) {
        this.score_percent = score_percent;
    }

    public String getExpressfee() {
        return expressfee;
    }

    public void setExpressfee(String expressfee) {
        this.expressfee = expressfee;
    }

    public String getModid() {
        return modid;
    }

    public void setModid(String modid) {
        this.modid = modid;
    }

    public String getDistrict_name() {
        return district_name;
    }

    public void setDistrict_name(String district_name) {
        this.district_name = district_name;
    }

    public String getReplycount() {
        return replycount;
    }

    public void setReplycount(String replycount) {
        this.replycount = replycount;
    }

    public String getGoodcount() {
        return goodcount;
    }

    public void setGoodcount(String goodcount) {
        this.goodcount = goodcount;
    }

    public String getSellcount() {
        return sellcount;
    }

    public void setSellcount(String sellcount) {
        this.sellcount = sellcount;
    }

    public String getCollectcount() {
        return collectcount;
    }

    public void setCollectcount(String collectcount) {
        this.collectcount = collectcount;
    }

    public String getStarscore() {
        return starscore;
    }

    public void setStarscore(String starscore) {
        this.starscore = starscore;
    }

    public String getStarcount() {
        return starcount;
    }

    public void setStarcount(String starcount) {
        this.starcount = starcount;
    }

    public String getImgurl() {
        return imgurl;
    }

    public void setImgurl(String imgurl) {
        this.imgurl = imgurl;
    }

    public String getImgurlbig() {
        return imgurlbig;
    }

    public void setImgurlbig(String imgurlbig) {
        this.imgurlbig = imgurlbig;
    }

    public String getPicurl() {
        return picurl;
    }

    public void setPicurl(String picurl) {
        this.picurl = picurl;
    }

    public String getPicurlbig() {
        return picurlbig;
    }

    public void setPicurlbig(String picurlbig) {
        this.picurlbig = picurlbig;
    }

    public String getImgcount() {
        return imgcount;
    }

    public void setImgcount(String imgcount) {
        this.imgcount = imgcount;
    }

    public String getImg2count() {
        return img2count;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getBuycontent() {
        return buycontent;
    }

    public void setBuycontent(String buycontent) {
        this.buycontent = buycontent;
    }

    public String getOrderby() {
        return orderby;
    }

    public void setOrderby(String orderby) {
        this.orderby = orderby;
    }

    public String getRegdate() {
        return regdate;
    }

    public void setRegdate(String regdate) {
        this.regdate = regdate;
    }

    public String getOne_spec() {
        return one_spec;
    }

    public void setOne_spec(String one_spec) {
        this.one_spec = one_spec;
    }

    public String getTwo_spec() {
        return two_spec;
    }

    public void setTwo_spec(String two_spec) {
        this.two_spec = two_spec;
    }

    public String getSpec() {
        return spec;
    }

    public void setSpec(String spec) {
        this.spec = spec;
    }

    public String getEnddate() {
        return enddate;
    }

    public void setEnddate(String enddate) {
        this.enddate = enddate;
    }

    public String getVolume() {
        return volume;
    }

    public void setVolume(String volume) {
        this.volume = volume;
    }

    public List<AttributeItems> getAttributeItems() {
        return attributeItems;
    }

    public void setAttributeItems(List<AttributeItems> attributeItems) {
        this.attributeItems = attributeItems;
    }

    public List<ImgItemsBean> getImg2Items() {
        return img2Items;
    }

    public void setImg2Items(String img2Items) {
        this.img2Items = new ArrayList<>();
    }

    public void setImg2Items(List<ImgItemsBean> img2Items) {
        this.img2Items = (ArrayList<ImgItemsBean>) img2Items;
    }

    public String getCollectflag() {
        return collectflag;
    }

    public void setCollectflag(String collectflag) {
        this.collectflag = collectflag;
    }

    public String getGoodflag() {
        return goodflag;
    }

    public void setGoodflag(String goodflag) {
        this.goodflag = goodflag;
    }

    public List<ImgItemsBean> getImgItems() {
        return imgItems;
    }

    public void setImgItems(ArrayList<ImgItemsBean> imgItems) {
        this.imgItems = imgItems;
    }
}
